package com.cn.broker;

import java.util.ArrayList;

public class ManyPullRequest {

    private final ArrayList<PullRequest> pullRequestList = new ArrayList<>();

    public void add(PullRequest pullRequest) {
        this.pullRequestList.add(pullRequest);
    }

    public void addAll(ArrayList<PullRequest> list) {
        this.pullRequestList.addAll(list);
    }

    public synchronized ArrayList<PullRequest> copyPullRequest() {
        if (!pullRequestList.isEmpty()) {
            ArrayList<PullRequest> tmp = new ArrayList<>();
            tmp = (ArrayList<PullRequest>) pullRequestList.clone();
            pullRequestList.clear();
            return tmp;
        }
        return null;
    }

}
